#pragma once
#include <memory>


template<class T>
class singleton
{
public:
	template<class... Args>
	static T* instance(Args&&... args)
	{
		if (instance_ == nullptr)
			instance_ = new T(std::forward<Args>(args)...);

		return instance_;
	}

	static void destroy_instance()
	{
		if (instance_ == nullptr)
			return;

		delete instance_;
		instance_ = nullptr;
	}

private:
	singleton() {}
	virtual ~singleton(){}

	singleton(const singleton&) {}
	singleton& operator =(const singleton) {}

private:
	static T* instance_;
};

template<class T> T* singleton<T>::instance_ = nullptr;